from django.shortcuts import render,HttpResponse
from rest_framework.generics import CreateAPIView
from rest_framework.response import Response
from users.models import *
# Create your views here.
from rest_framework.views import APIView
from serializers import CreateUserSerializer

# 判断账号是否存在
class UsernameCountView(APIView):
    def get(self,request,username):

        count = User.objects.get(username=username).count()

        return Response({
            "username": username,
            "count": "count"
        })
# 判断电话是否存在
class MobileCountView(APIView):
    def get(self,request,mobile):

        count = User.objects.get(mobile = mobile).count()

        return Response({
            "mobile": mobile,
            "count": count
        })

class UserCreatView(CreateAPIView):
    serializer_class = CreateUserSerializer